package com.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import com.server.entity.UcenterUser;
import com.server.mapper.UcenterUserMapper;
import com.server.service.IUcenterUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import lombok.AllArgsConstructor;
import com.server.util.Result;
import java.util.ArrayList;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author
 * @since 2020-04-03
 */
@Service
@AllArgsConstructor
public class UcenterUserServiceImpl extends ServiceImpl<UcenterUserMapper, UcenterUser> implements IUcenterUserService {

	/**
     * 新增
     *
     * @author
     * @Date 2020-04-03
     */
	@Override
	@Transactional(rollbackFor = {Exception.class})
    public Result add(UcenterUser ucenteruser){
		return this.baseMapper.insert(ucenteruser)>0?Result.returnData(ucenteruser):Result.error("操作失败");
	}

    /**
     * 批量删除
     *
     * @author
     * @Date 2020-04-03
     */
	@Override 
	@Transactional(rollbackFor = {Exception.class})
    public Boolean delete(String idsStr){
		String [] ids =idsStr.split(",");
        if(ids.length>0){
            List<String> resultList= new ArrayList<>(Arrays.asList(ids));
            if(this.baseMapper.deleteBatchIds(resultList)<=0){
                return false;
            }
        }
        return true;
	}

    /**
     * 更新
     *
     * @author
     * @Date 2020-04-03
     */
	@Override
    @Transactional(rollbackFor = {Exception.class})	
    public Result update(UcenterUser ucenteruser){
		return this.baseMapper.updateById(ucenteruser)>0?Result.ok("操作成功"):Result.error("操作失败");
	}

    /**
     * 根据id查询详情
     *
     * @author
     * @Date 2020-04-03
     */
	@Override 
    public UcenterUser findById(String id){
		return this.baseMapper.selectById(id);
	}


    /**
     * 查询分页数据 
     *
     * @author
     * @Date 2020-04-03
     */
	@Override 
     public Result<List<UcenterUser>> findPage(Page<UcenterUser> page){
	 
		return null;
	 }

}
